package zyh.struts2.action;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class FileDownloadAction extends ActionSupport {
    private String test;

    @Override
    public String execute() throws Exception {
        return SUCCESS;
    }

    public InputStream getTarget()throws FileNotFoundException{
        System.out.println(test);
        String path= ServletActionContext.getServletContext().getRealPath("/upload");
        System.out.println(path);
        return new FileInputStream(new File(path,test));
    }

    public String getTest() {
        return test;
    }

    public void setTest(String test) {
        this.test = test;
    }
}
